AngouriMath

Try it live

Navigation

Setting`1


← Back to list of classes

Description

Summary

This class for configuring some internal mechanisms from outside

Type parameter "T"

Those configurations can be of different types

Remarks

A setting is one object for the whole process, and what it holds is per *flow*, not
per thread: the stacks of values of every setting live in one
AsyncLocal`1, as a State. A scope
opened before an await is therefore still in force after it, and a
scope opened inside a task is invisible to that task's siblings and to whatever
started it. Backing the field with [ThreadStatic] gave neither: a continuation
resumed on a pool thread saw the defaults, and a thread returned to the pool carried
whatever scope was left on it into the next caller.
The states are immutable, which is what makes the reference safe to share. An
AsyncLocal`1 copies on assignment to Value and on nothing else, so if a state could be mutated in place, two flows holding it
would write over each other. Opening and closing a scope therefore assign another
state, rather than editing one.

Members

























Angouri © 2019-2026 · Project's repo · Site's repo · Octicons · Transparency · 6018 pages online